extends Node


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass

func update_health_bar():
	var max_health = %Player.get_max_health()
	var health = %Player.get_health()
	var value = (health / max_health) * 100
	$PanelContainer/Control/display/Health.value = value
	if (value <= 50 && value > 25 && $PanelContainer/Control/BarBase.frame != 1):
		$PanelContainer/Control/BarBase.frame = 1
		$PanelContainer/AudioStreamPlayer2D.play()
	elif (value <= 25 && $PanelContainer/Control/BarBase.frame != 2):
		$PanelContainer/Control/BarBase.frame = 2
		$PanelContainer/AudioStreamPlayer2D.play()
